Chord diagram: User flow

## [1] 105892      6
## OGR data source with driver: ESRI Shapefile 
## Source: "/Users/Matteo/Dropbox/bcn_project/data/barioswithnames", layer: "barioswithnames"
## with 68 features
## It has 5 fields

Local and Tourist distribution per district/month

user_months2 = read_csv("input/user_months2.csv")
head(user_months2)
## # A tibble: 6 x 9
##      X1 district month num_users.Locals avglat.Locals avglong.Locals
##   <dbl> <chr>    <chr>            <dbl>         <dbl>          <dbl>
## 1     1 Ciutat … 2015…            23400          41.4           2.18
## 2     2 Ciutat … 2015…            20231          41.4           2.18
## 3     3 Ciutat … 2015…            22357          41.4           2.18
## 4     4 Ciutat … 2015…            30397          41.4           2.18
## 5     5 Ciutat … 2015…            23858          41.4           2.18
## 6     6 Ciutat … 2015…            32795          41.4           2.18
## # ... with 3 more variables: num_users.Tourists <dbl>,
## #   avglat.Tourists <dbl>, avglong.Tourists <dbl>
colors <- c("#3093e5", "#fcba50")


map <- leaflet(shapefile) %>% 
  # addProviderTiles(providers$CartoDB.DarkMatter) %>% 
  addPolygons(
    fillColor = "white",
    fillOpacity = 0.8, 
    color = "black",
    # opacity =0.1,
    weight = 1, 
    popup = ~htmlEscape(district),
    group = "shape")


map <- map %>%  addMinicharts(
  lng = user_months2$avglong.Locals, lat = user_months2$avglat.Locals, 
  chartdata = user_months2[, c("num_users.Locals", "num_users.Tourists")],
  type = "pie",
  time = user_months2$month,
  colorPalette = colors,
  width = 25, height = 25
)

map
saveWidget(map, "minichertmap.html")

Path performed by local users in the city